<%@ page language="java" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%--增加/编辑人员页面--%>
<!DOCTYPE HTML>
<html>
<head>
	<base href="<%=basePath%>pages/weixin/">
	<meta charset="utf-8">
 	<meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0">
	<meta name="apple-mobile-web-app-capable" content="yes"/>
	<meta name="format-detection" content="telephone=no">
	<meta names="apple-mobile-web-app-status-bar-style" content="black-translucent"/>
	<meta name="apple-touch-fullscreen" content="yes"/>
	
	<title>学生缺勤登记</title>
 	<link rel="stylesheet" href="../../static/weui/weuix.min.css"/>
 	<link rel="stylesheet" href="../../static/selectpage/selectpage.base.css" type="text/css">
 	<style>
 	.mybtn {
 		margin-top: 10px;
 		margin-bottom: 20px;
 	}
 	.page-bd-15 {
 		padding-bottom: 20px;
 	}
 	</style>
	<script type="text/javascript" src="../../static/jquery-1.10.2.min.js"></script>
	<script type="text/javascript" src="../../static/selectpage/selectpage.min.js"></script>
	<script>
		function len2(str) {
			if(str.length==1) return '0'+str;
			return str;
		}
		var json = $.parseJSON('${gradesJson}');
		$(function() {
			var d = new Date();
			var str = d.getFullYear()+'-'+len2(d.getMonth()+1+"")+'-'+len2(d.getDate()+"");
			$('#datex').val(str);
			
			$('#grade').change(function(x) {
				var idx = $(this).find(':selected').attr('d');
				var arr = json[idx].clazzList;
				
				$('#clazz').empty();
				$('#clazz').append('<option value="" disabled selected hidden>请选择</option>');
				for(var i=0; i<arr.length; i++) {
					$('#clazz').append('<option value="'+arr[i].oid+'">'+arr[i].name+'</option>');					
				}
			});
			
			$('#clazz').change(function() {
				// 发送ajax请求
				var clazz = $(this).val();
				$.getJSON('<%=path%>/wechat/listStudentWeixin.do', {clazzid: clazz}, function(json) {
					//初始化插件
					$('#in').selectPage({
					    showField: 'name',
					    keyField: 'oid',
					    data: json,
					    orderBy : ['sn'],
					  	//启用多选模式
					    multiple : true,
					    //设置选中项目后不关闭列表
					    selectToCloseList : false
					});
				});
				
			});
		});		
		
		function checkForm() {
			if($('#clazz').val() == '') {
				alert('班级不能为空！');
				return false;
			}
			if($('#jieciType').val() == '') {
				alert('节次不能为空！');
				return false;
			}
			if($('#course').val() == '') {
				alert('课程不能为空！');
				return false;
			}
			if($('#clazz').val() == '') {
				alert('班级不能为空！');
				return false;
			}
			return true;
		}
		
	</script>

</head>
<body ontouchstart class="page-bg">

<div class="page-bd-15">
	<div class="weui_cells_title">缺勤信息</div>
	<form action="<%=path%>/wechat/saveKaoQinWeixin.do" method="post" onsubmit="return checkForm()">
		<input type="hidden" name="uid" value="${user.userId}">
		<input type="hidden" name="kaoQin.teacher.userId" value="${user.userId}">
		<div class="weui_cells weui_cells_form">
			<div class="weui_cell">
		  		<div class="weui_cell_hd"><label for="" class="weui_label">日 期</label></div>
		        <div class="weui_cell_hd weui_cell_primary">
		          <input class="weui_input" name="kaoQin.cdate" id="datex" type="text" readonly="readonly">
		 		</div>
		 	</div>
		    <div class="weui_cell">
		        <div class="weui_cell_hd"><label for="" class="weui_label">年 级</label></div>
		        <div class="weui_cell_bd weui_cell_primary">
		           	<select id="grade" class="weui_input">
		           		<option value="" disabled selected hidden>请选择</option>
				   		<c:forEach var="g" items="${grades}" varStatus="idx">
							<option value="${g.oid}" d='${idx.index}'>${g.name}</option>
						</c:forEach>
				 	</select>
		        </div>
		    </div> 
		    <div class="weui_cell">
		        <div class="weui_cell_hd"><label for="" class="weui_label">班 级</label></div>
		        <div class="weui_cell_bd weui_cell_primary">
		        	<select name="kaoQin.clazz.oid" id="clazz" class="weui_input">
		        		<option value="" disabled selected hidden>请选择</option>
				 	</select>
		        </div>
		    </div> 
		    <div class="weui_cell">
		        <div class="weui_cell_hd"><label for="" class="weui_label">节 次</label></div>
		        <div class="weui_cell_bd weui_cell_primary">
		           	<select name="kaoQin.jieciType.dicId" id="jieciType" class="weui_input">
		           		<option value="" disabled selected hidden>请选择</option>
				   		<c:forEach var="c" items="${jieciTypes}">
							<option value="${c.dicId}">${c.itemValue}</option>
						</c:forEach>
				 	</select>
		        </div>
		    </div> 
		    <div class="weui_cell">
		        <div class="weui_cell_hd"><label for="" class="weui_label">课 程</label></div>
		        <div class="weui_cell_bd weui_cell_primary">
		           	<select name="kaoQin.course.oid" id="course" class="weui_input">
		           		<option value="" disabled selected hidden>请选择</option>
				   		<c:forEach var="c" items="${courses}">
							<option value="${c.oid}">${c.name}</option>
						</c:forEach>
				 	</select>
		        </div>
		    </div> 
		    <div class="weui_cell">
		        <div class="weui_cell_hd"><label for="" class="weui_label">缺勤类型</label></div>
		        <div class="weui_cell_bd weui_cell_primary">
		           	<select name="kaoQin.type.dicId" id="type" class="weui_input">
		           		<option value="" disabled selected hidden>请选择</option>
				   		<c:forEach var="c" items="${types}">
							<option value="${c.dicId}">${c.itemValue}</option>
						</c:forEach>
				 	</select>
		        </div>
		    </div> 
		    
		    <div class="weui_cell">
		       	<div class="weui_cell_bd weui_cell_primary">
		        	<input type="text" readOnly='readOnly' name="student_ids" class="weui_textarea" id="in" placeholder="请选择缺勤学生（全勤留空）">
		        </div>
		    </div>
		</div>
	    <input type="submit" class="weui_btn weui_btn_primary mybtn" value="保 存">
	</form>
</div>
</body>
</html>
